package com.hippoDocker.commons.entities;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @ClassName CommonResult
 * @Description TODO 服务返回结果类
 * @Author hippoDocker
 * @Date 2022/5/30 0:32
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonResult<T> {
    private Integer code;
    private String message;
    private T data;

    public CommonResult(Integer code, String message) {
        this(code, message, null);
    }

    public static <T> CommonResult<T> success(T data){
        return new CommonResult<T>(200, "success", data);
    }
    public static <T> CommonResult<T> success(String message,T data){
        return new CommonResult<T>(200, message, data);
    }
    public static <T> CommonResult<T> failed(String message){
        return new CommonResult<T>(500, message, null);
    }
}
